<template>
  <div class="main_box" style="padding:10px">
    <div class="add_wrap">
      <el-form label-width="200px">
        <div class="tit">
          <h2>基础信息</h2>
          <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList">返回</el-button>
        </div>
        <el-row>
          <el-form-item label="申请小区:">
            <span>{{dataInfo.villageName}}</span>
          </el-form-item>
          <el-form-item label="小区地址:">
            <span>{{dataInfo.provinceName}}{{dataInfo.cityName}}{{dataInfo.areaName}}{{dataInfo.streetName}}{{dataInfo.address}}</span>
          </el-form-item>
          <el-form-item label="经纬度:">
            <span>{{dataInfo.longitude}},{{dataInfo.latitude}}</span>
          </el-form-item>
          <el-form-item label="物业名称:">
            <span>{{dataInfo.pmcName}}</span>
          </el-form-item>
          <el-form-item label="物业电话:">
            <span>{{dataInfo.pmcPhone}}</span>
          </el-form-item>
          <el-form-item label="物业备用电话:">
            <span>{{dataInfo.pmcPhoneTwo}}</span>
          </el-form-item>
          <el-form-item label="120行车路线:">
            <span>{{dataInfo.sosRoute}}</span>
          </el-form-item>
          <el-form-item label="120电话:">
            <span>{{dataInfo.sosPhone}}</span>
          </el-form-item>
          <el-form-item label="申请人:">
            <span>{{ dataInfo.linkMan}}</span>
          </el-form-item>
          <el-form-item label="申请人电话:">
            <span>{{dataInfo.linkPhone}}</span>
          </el-form-item>
          <el-form-item label="申请说明:">
            <span>{{dataInfo.applyDesc}}</span>
          </el-form-item>
          <el-form-item label="申请时间:">
            <span>{{ dataInfo.createDate }}</span>
          </el-form-item>

          <el-form-item label="审核人:">
            <span>{{ dataInfo.modifyUserName}}</span>
          </el-form-item>
          <el-form-item label="审核时间:">
            <span>{{ dataInfo.modifyDate }}</span>
          </el-form-item>
          <el-form-item label="审核状态:">
            <span>{{ formatApplyState(dataInfo.applyState)}}</span>
          </el-form-item>
          <el-form-item label="审核不通过原因:" v-if="dataInfo.applyState == 3">
            <span>{{ dataInfo.remark}}</span>
          </el-form-item>

          <el-form-item label="审核不通过原因:" v-if="dataInfo.applyState == 1">
            <el-input type="textarea" v-model="dataForm.remark"></el-input>
          </el-form-item>
        </el-row>

        <el-row type="flex" justify="center">
          <el-button v-if="dataInfo.applyState == 1" plain type="success" @click="checkApply(2)">审核通过并创建</el-button>
          <el-button v-if="dataInfo.applyState == 1" plain type="danger" @click="checkApply(3)">审核不通过</el-button>
          <el-button plain @click="returnList">返 回</el-button>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
  import VillageApplyApi from '@/api/address/villageApply';

  export default {
    data() {
      return {
        dataInfo: {},
        dataForm:{
          villageApplyId:"",
          applyState:"",
          remark:"",
        }
      };
    },
    computed: {

    },
    mounted() {
      this.dataForm.villageApplyId = this.$route.query.id
      this.getData()
    },
    methods: {
      formatApplyState(cellValue){
        if (cellValue === 1) {
          return '待审核'
        }else if (cellValue === 2) {
          return '审核通过'
        } else if (cellValue === 3) {
          return '审核不通过'
        }
      },
      checkApply(state){
        let _this = this
        if (state == 3){
          if (_this.dataForm.remark == null || this.dataForm.remark == ''){
            _this.$message.warning("请输入审核不通过原因!")
            return
          }
        }
        let param = {
          id: _this.dataForm.villageApplyId,
          state:state,
          content: _this.dataForm.remark
        }
        VillageApplyApi.approvalVillage(param)
          .then(data => {
            _this.$Utils.notifySuccess()
            _this.returnList();
          })
      },
      getData() {
        VillageApplyApi.getVillageApplyInfo({id: this.$route.query.id}).then(res => {
          this.dataInfo = res.data

        })
      },
      returnList() {
        this.$store.dispatch('delView', this.$route);
        this.$router.push({path: '/address/villageApplyManagement'})
      }
    },

  }

</script>
<style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>
